#ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H

#include <QWidget>
//#include <QMediaPlayer>
//#include <QVideoWidget>
#include <QUrl>
#include <QDebug>
#include <QPaintEvent>
#include <QTimer>
#include <QProcess>
#include <QKeyEvent>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <QMouseEvent>

#include "keythread.h"
#include "loading.h"
#include "config.h"
#include "basewidget.h"

namespace Ui {
class VideoWidget;
}

class VideoWidget : public BaseWidget
{
    Q_OBJECT

public:
    explicit VideoWidget(QString path, QWidget *parent = nullptr);
    ~VideoWidget();

    //Ui::VideoWidget *ui;

   // QMediaPlayer *player;
 //   QVideoWidget *videoWidget;

    void paintEvent(QPaintEvent *event) override;

    QStringList list;
    int index = 0;
    QProcess process;

    int fd;
    void slave_write_cmd(int fifo_fd,char *cmd);
    void keyPressEvent(QKeyEvent *event) override;
    void playVideo();

    void mouseReleaseEvent(QMouseEvent *) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;

    bool press = false;
    QPoint pos;
    bool move = false;
public slots:
    //void error(QMediaPlayer::Error);
    void onReadyRead();
    void slotChangeVideo(QString);
private slots:
    void KeyEvent(Key_t, int)override;
signals:
    void finishLoad();
    void sigChangeVideo(int);
};

#endif // VIDEOWIDGET_H
